package com.shioirikukuri.controller;

import com.shioirikukuri.entity.ServiceType;
import com.shioirikukuri.service.IServiceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/service-types")
public class ServiceTypeController {

	@Autowired
	private IServiceTypeService serviceTypeService;

	@GetMapping
	public List<ServiceType> getAllServiceTypes() {
		return serviceTypeService.getAllServiceTypes();
	}

	@GetMapping("/{serviceId}")
	public ServiceType getServiceTypeById(@PathVariable Integer serviceId) {
		return serviceTypeService.getServiceTypeById(serviceId);
	}

	@PostMapping
	public void createServiceType(@RequestBody ServiceType serviceType) {
		serviceTypeService.createServiceType(serviceType);
	}

	@PutMapping("/{serviceId}")
	public void updateServiceType(@PathVariable Integer serviceId, @RequestBody ServiceType serviceType) {
		serviceTypeService.updateServiceType(serviceType);
	}

	@DeleteMapping("/{serviceId}")
	public void deleteServiceTypeById(@PathVariable Integer serviceId) {
		serviceTypeService.deleteServiceTypeById(serviceId);
	}
}